#include "FiveWin.ch"

function GetObjBmps() ; return {}

//----------------------------------------------------------------------------//

function RecEdit( cTitle, oBrwParent )

   local oWndRec, oBrw, oIco, oFont, oName, oType, oLen, oDec
   local cAlias := Alias()
   local nField := 1
   local aInfo  := DbStruct()

   DEFINE ICON oIco RESOURCE "Record"

   DEFINE WINDOW oWndRec FROM 1, 43 TO 23, 79 ;
      TITLE cTitle MDICHILD ;
      ICON oIco

   DEFINE FONT oFont NAME "Arial" SIZE 6, 15 BOLD

   @ 2, 0 LISTBOX oBrw FIELDS "" ;
      HEADERS "", "Field", "Value" ;
      SIZES   16,      95,    400 ;
      SIZE 400, 400 ;
      COLOR oBrwParent:nClrText, oBrwParent:nClrPane ;
      FONT oFont ;
      ON CHANGE ( oWndRec:oMsgBar:cMsgDef := "Name: " + aInfo[ nField ][ 1 ],;
                  oWndRec:SetMsg( "Name: " + aInfo[ nField ][ 1 ] ),;
                  oType:SetText( "Type: " + aInfo[ nField ][ 2 ] ),;
                  oLen:SetText( "Len: " + cValToChar( aInfo[ nField ][ 3 ] ) ),;
                  oDec:SetText( "Dec: " + cValToChar( aInfo[ nField ][ 4 ] ) ) )

   oBrw:bLine     = { || ( cAlias )->( FldInfo( nField, aInfo[ nField ][ 2 ] ) ) }
   oBrw:bLogicLen = { || ( cAlias )->( FCount() ) }
   oBrw:bGoTop    = { || nField := 1 }
   oBrw:bGoBottom = { || nField := ( cAlias )->( FCount() ) }
   oBrw:bSkip     = { | nSkip, nOld | nOld := nField, nField += nSkip,;
                  nField := Min( Max( nField, 1 ), ( cAlias )->( FCount() ) ),;
                  nField - nOld }

   SET MESSAGE OF oWndRec TO "Name: " + aInfo[ nField ][ 1 ]

   DEFINE MSGITEM oDec OF oWndRec:oMsgBar ;
      PROMPT "Dec: " + cValToChar( aInfo[ nField ][ 4 ] ) SIZE 50

   DEFINE MSGITEM oLen OF oWndRec:oMsgBar ;
      PROMPT "Len: " + cValToChar( aInfo[ nField ][ 3 ] ) SIZE 50

   DEFINE MSGITEM oType OF oWndRec:oMsgBar ;
      PROMPT "Type: " + aInfo[ nField ][ 2 ] SIZE 50

   oWndRec:SetControl( oBrw )

   ACTIVATE WINDOW oWndRec ;
      VALID ( oWndRec := nil, .t. )            // Destroy the Object

return oWndRec

//----------------------------------------------------------------------------//

static function FldInfo( nField, cType )

   local uData := FieldGet( nField )

return { GetObjBmps()[ At( cType, "ABCDLNMOU" ) ], Field( nField ),;
         cValToChar( uData ) }

//----------------------------------------------------------------------------//

